<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>二级导航栏</title>
		<style>
			* {
				margin: 0;
				padding: 0;
			}
			body {
				width: 100vm;
			}
			ul,
			li {
				list-style: none;
			}
			a {
				text-decoration: none;
				color: #333;
			}
			.navbar {
				width: 100%;
				height: 70px;
				background-color: #fff;
				box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
			}
			.navbar .nav {
				width: 1200px;
				height: 100%;
				margin: 0 auto;
			}
			.navbar .nav ul {
				position: relative;
				display: flex;
				justify-content: space-around;
				width: 100%;
				height: 100%;
			}
			.navbar .nav ul li {
				width: 100%;
				height: 100%;
			}
			.navbar .nav ul li a {
				display: block;
				width: 100%;
				height: 100%;
				line-height: 70px;
				text-align: center;
			}
			.navbar .nav ul li:hover ol {
				transform: scaleY(1);
			}
			.navbar .nav ul li ol {
				width: 100%;
				background: #fff;
				box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
				transform: scaleY(0);
				transform-origin: 50% 0;
				transition: all 0.6s;
			}
			.navbar .nav ul li ol li {
				height: 70px;
				border-bottom: 1px solid #ebebeb;
			}
			.navbar .nav ul li ol li:hover {
				background: #ccc;
			}
			.navbar .nav ul li ol li a {
				display: block;
				width: 100%;
				height: 100%;
				line-height: 70px;
				text-align: center;
			}
			.navbar .nav ul .underline {
				position: absolute;
				bottom: 0;
				left: 0;
				width: 240px;
				height: 6px;
				background-color: #cc3333;
				border-top-left-radius: 6px;
				border-top-right-radius: 6px;
				transition: all 0.5s;
				pointer-events: none;
			}
			.navbar .nav ul .underline::before {
				content: "";
				position: absolute;
				top: -6px;
				left: calc(50% - 6px);
				/* width: 0;
				height: 0;
				border-width: 6px;
				border-style: solid;
				border-color: transparent transparent #cc3333; */
				/* 三角形的第二种方法 */
				width: 12px;
				height: 6px;
				background: inherit;
				clip-path: polygon(0 100%, 50% 0, 100% 100%);
			}
			.navbar .nav ul li:nth-child(2):hover ~ .underline {
				left: 240px;
				background-color: #ff9933;
			}
			.navbar .nav ul li:nth-child(3):hover ~ .underline {
				left: 480px;
				background-color: #339933;
			}
			.navbar .nav ul li:nth-child(4):hover ~ .underline {
				left: 720px;
				background-color: #0099cc;
			}
			.navbar .nav ul li:nth-child(5):hover ~ .underline {
				left: 960px;
				background-color: #9966cc;
			}
		</style>
	</head>
	<body>
		<!-- .navbar>.nav>ul>li*5>a{一级菜单$}+(ol>li*6>a{二级菜单$}) -->
		<div class="navbar">
			<div class="nav">
				<ul>
					<li>
						<a href="javascript:void()">一级菜单1</a>
					</li>
					<li>
						<a href="javascript:void()">一级菜单2</a>
						<ol>
							<li><a href="javascript:void()">二级菜单1</a></li>
							<li><a href="javascript:void()">二级菜单2</a></li>
							<li><a href="javascript:void()">二级菜单3</a></li>
							<li><a href="javascript:void()">二级菜单4</a></li>
							<li><a href="javascript:void()">二级菜单5</a></li>
							<li><a href="javascript:void()">二级菜单6</a></li>
						</ol>
					</li>
					<li>
						<a href="javascript:void()">一级菜单3</a>
						<ol>
							<li><a href="javascript:void()">二级菜单1</a></li>
							<li><a href="javascript:void()">二级菜单2</a></li>
							<li><a href="javascript:void()">二级菜单3</a></li>
							<li><a href="javascript:void()">二级菜单4</a></li>
							<li><a href="javascript:void()">二级菜单5</a></li>
							<li><a href="javascript:void()">二级菜单6</a></li>
						</ol>
					</li>
					<li>
						<a href="javascript:void()">一级菜单4</a>
						<ol>
							<li><a href="javascript:void()">二级菜单1</a></li>
							<li><a href="javascript:void()">二级菜单2</a></li>
							<li><a href="javascript:void()">二级菜单3</a></li>
							<li><a href="javascript:void()">二级菜单4</a></li>
							<li><a href="javascript:void()">二级菜单5</a></li>
							<li><a href="javascript:void()">二级菜单6</a></li>
						</ol>
					</li>
					<li>
						<a href="javascript:void()">一级菜单5</a>
					</li>
					<li class="underline"></li>
				</ul>
			</div>
		</div>
	</body>
</html>
